<!--设置模块唯一ID-->
<div id="aq_shangpinbianmaguanli">
<!--标题、面包屑-->
<section class="content-header">
    <h1>
        商品编码管理
        <small>奥桥</small>
    </h1>
    <ol class="breadcrumb">
        <li><a href="#"><i class="fa fa-dashboard"></i> 首页</a></li>
        <li>奥桥</li>
        <li class="active">商品编码管理</li>
    </ol>
</section>
<!--列表-->
<section class="content">
    <div class="row">
        <div class="col-xs-12">
            <div class="box">
                <div class="box-header">
                    <div class="btn-group pull-left" data-type="actionBar">
                        <button type="button" class="btn btn-default" data-action="add"><i class="fa fa-pencil"></i> 编码调整申请</button>
                        <button type="button" class="btn btn-default" data-action="confirm"><i class="fa fa-pencil"></i> 采购审批</button>
                        <button type="button" class="btn btn-default" data-action="zong_confirm"><i class="fa fa-pencil"></i> 总经理审批</button>
                    </div>
                    <div class=" pull-right" data-type="columnControl">
                    </div>
                    <div class=" pull-right " data-type="searchControl">
                    </div>
                    <div class="clearfix"></div>
                </div>
                <div class="box-body">
                    <table class="table table-bordered table-striped table-hover"></table>
                </div>
            </div>
        </div>
    </div>
</section>

<script>
    USEN(function () {
        //模块ID(全系统唯一)
        var id = "#aq_shangpinbianmaguanli";
        var add = "aq_shangpinbianmaguanli_add";
        var confirm = "aq_shangpinbianmaguanli_confirm";
        var zong_confirm = "aq_shangpinbianmaguanli_zong_confirm";

        //定义页面变量
        var $el = $(id);
        var $actionBar = $el.find("[data-type=actionBar]");
        var tableId = id + " table.table";
        var $table = $(tableId);
        var myTable;


        //定义增\删\改 方法
        var editor = {
            add: function () {
                USEN.load(USEN.router[add]);
            },
            confirm: function () {
                USEN.load(USEN.router[confirm]);
            },
            zong_confirm: function () {
                USEN.load(USEN.router[zong_confirm]);
            },
        };

        // 绑定列表编辑按钮事件
        $actionBar.find("[data-action]").on("click", function () {
            var action = $(this).data("action");
            var $selected = $table.find('tr.selected');
            switch (action) {
                case "add" :
                    editor.add();
                    break;
                case "confirm" :
                    if ($selected.length > 0) {
                        editor.confirm(myTable.row($selected).data());
                    } else {
                        //提示"请选中要修改的行"
                        USEN.modal({
                            title: "提示",
                            content: "请选中要修改的行.",
                            cancelBtn: true,
                            cancelTxt: "关闭"
                        })
                    }
                    break;
                case "zong_confirm" :
                    if ($selected.length > 0) {
                        editor.zong_confirm(myTable.row($selected).data());
                    } else {
                        //提示"请选中要修改的行"
                        USEN.modal({
                            title: "提示",
                            content: "请选中要修改的行.",
                            cancelBtn: true,
                            cancelTxt: "关闭"
                        })
                    }
                    break;
            }
        });

        //初始化datatable数据列表
        myTable = new USEN.Datatable({
            "scrollX":false,
            //设置ID
            "id": tableId,
            //设置列控制模块容器
            "columnControl": id + " [data-type=columnControl]",
            //设置搜索模块容器
            "searchControl": id + " [data-type=searchControl]",
            //配置服务
            "ajax": "./simdata/common_table_ation.json",
            //列设置
            "columns": [
                {
                    data: null,
                    defaultContent: '',
                    className: 'select-checkbox',
                    orderable: false, searchable: false,
                    width: "30px"
                },
                { "title": "编号", "data": "p2"},
                { "title": "状态", "data": "p3"},
                { "title": "申请人", "data": "p4" },
                { "title": "申请时间", "data": "p5" },
            ]
        })
    });
</script>
</div>